//
//  PSGameInputOptionsTest.m
//  PrefCore
//
//  Created by Sergey on 2/6/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "PSGameInputOptions.h"

@interface PSGameInputOptionsTests : XCTestCase

@end

@implementation PSGameInputOptionsTests

- (void)testInit {
    PSGameInputOptions *opt = [[PSGameInputOptions alloc] init];
    XCTAssertNotNil(opt);
    XCTAssertEqual(opt.bid, [PSBid bidNone]);
    XCTAssertEqual(opt.score, 0);
    XCTAssertEqual(opt.hand, (uint8_t)0);
    XCTAssertFalse(opt.isHumanInputRequired);
}

-(void)testFlags {
    PSGameInputFlag testFlags[] = {
        kGameInputWaitForTouch
    ,   kGameInputWaitForPool
    ,   kGameInputTrickingTenCheck
    ,   kGameInputTricksMinusOne
    ,   kGameInputMisereConfirm
    };
    const int count = sizeof(testFlags)/sizeof(testFlags[0]);
    PSGameInputOptions *opt = [[PSGameInputOptions alloc] init];
    for (int mask = 0 ; mask != 1<<count ; mask++) {
        PSGameInputFlag flag = 0;
        for (int i = 0 ; i != count ; i++) {
            if ((1 << i) & mask) {
                flag |= testFlags[i];
            }
        }
        [opt clear];
        XCTAssertFalse([opt isHumanInputRequired]);
        [opt setFlag:flag];
        if (flag) {
            XCTAssertTrue([opt isHumanInputRequired]);
        } else {
            XCTAssertFalse([opt isHumanInputRequired]);
        }
        for (int i = 0 ; i != count ; i++) {
            if ((1 << i) & mask) {
                XCTAssertTrue([opt checkFlag:testFlags[i]]);
            } else {
                XCTAssertFalse([opt checkFlag:testFlags[i]]);
            }
        }
        
    }
}

@end
